<template>
  <div class="ShopDialog">
    <el-dialog title="修改价格" v-model="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="价格形式" prop="priceType">
          <el-radio-group v-model="form.priceType">
            <el-radio label="1">一口价</el-radio>
            <el-radio label="2">价格区间</el-radio>
            <el-radio label="3">显示折扣价</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="价格" v-if="form.priceType == 1">
          <el-col :span="4">
            <el-input
              v-model="form.price"
              autocomplete="off"
            ></el-input> </el-col
          >元
        </el-form-item>
        <el-form-item label="价格区间" v-else-if="form.priceType == 2">
          <el-col :span="4">
            <el-input v-model="form.price" autocomplete="off"></el-input>
          </el-col>
          <el-col class="line" :span="2">元—</el-col>
          <el-col :span="4">
            <el-input
              v-model="form.price2"
              autocomplete="off"
            ></el-input> </el-col
          >元
        </el-form-item>
        <el-form-item label="折扣区间" v-else>
          <el-col :span="4">
            <el-input
              placeholder="市场价"
              v-model="form.price"
              autocomplete="off"
            ></el-input>
          </el-col>
          <el-col class="line" :span="2">元—</el-col>
          <el-col :span="4">
            <el-input
              placeholder="现价"
              v-model="form.price2"
              autocomplete="off"
            ></el-input> </el-col
          >元
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="goModifyPrice">确 定</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, toRefs, ref } from 'vue'
import { modifyPrice } from '@/service/main/main'
export default defineComponent({
  props: {
    goodsId: {
      type: String,
      default: '',
    },
  },
  setup(props) {
    let dialogFormVisible = ref(false)
    let form = reactive({
      priceType: '1',
      region: '',
      price: '',
      price2: '',
    })
    // 修改价格请求
    const goModifyPrice = () => {
      dialogFormVisible.value = false
      modifyPrice(form.priceType, form.price, form.price2, props.goodsId)
    }

    return {
      dialogFormVisible,
      form,
      goModifyPrice,
    }
  },
})
</script>

<style scoped></style>
